﻿using Microsoft.EntityFrameworkCore;

namespace 第二课堂评审系统.Models
{
    public class _MyDbContext : DbContext
    {
        public DbSet<User> Users { get; set; }
        public DbSet<Role> Roles { get; set; }
        public DbSet<Project> Projects { get; set; }
        public DbSet<Preliminary> Preliminaries { get; set; }
        public DbSet<Partnar> Partnars { get; set; }
        public DbSet<OperationTime> OperationTimes { get; set; }
        public DbSet<Notice> Notices { get; set; }
        public DbSet<Final> Finals { get; set; }
        public DbSet<Achievement> Achievements { get; set; }
        public DbSet<ControllActionTime> ControllActionTimes { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            base.OnConfiguring(optionsBuilder);
            var connectString = "server=localhost;user=root;password=;database=SecondClassJudge";
            var serverVersion = new MySqlServerVersion(new Version(8, 0, 34));
            optionsBuilder.UseMySql(connectString, serverVersion);
        }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            modelBuilder.ApplyConfigurationsFromAssembly(this.GetType().Assembly);
        }
    }
}
